﻿using Inovout.Cloud.Data.Blob.Models;
using Inovout.Repositories;
using NHibernate.Criterion;

namespace Inovout.Cloud.Data.Blob.Repositories
{
    public class FileRepository : DataObjectRepository<File>
    {
        public long SumSpace(string owner)
        {
            return base.OpenSession().CreateCriteria<File>()
                .Add(Restrictions.Eq("Owner", owner).IgnoreCase())
                .SetProjection(Projections.Sum("Length")).UniqueResult<long>();
        }
    }
}
